package com.ssy.lingxi.settle.accounts.handler.validator;


import com.ssy.lingxi.settle.accounts.handler.annotation.ApplyAmountStatusAnnotation;
import com.ssy.lingxi.settle.accounts.model.constant.ApplyAmountStatusEnum;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Arrays;

/**
 * 请款单状态校验注解验证类
 * @author Saske
 * @version 2.0.0
 * @date 2021-12-8
 */
public class ApplyAmountStatusValidator implements ConstraintValidator<ApplyAmountStatusAnnotation,Integer> {
    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {
        if (value == null){
            return false;
        }
        return Arrays.stream(ApplyAmountStatusEnum.values()).anyMatch(e -> e.getCode().equals(value));
    }
}
